import router from './router'
import store from './store'

//白名单
const whiteList = ['/reg','/login' ]

router.beforeEach((to,from,next)=>{
  const token = store.state.token
  if(token){
    if(to.path === '/login'){
      next('/')
    }else{
      next()
    }
  }else{
    if(whiteList.includes(to.path)){
      next()
    }else {
      next('/login')
    }
  }
})